import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Home',
    component: () => import('@/pages/Home.vue'),
    meta: {
      title: '房贷计算器'
    }
  },
  {
    path: '/payment-plan',
    name: 'PaymentPlan',
    component: () => import('@/pages/PaymentPlan.vue'),
    meta: {
      title: '还款计划'
    }
  },
  {
    path: '/analysis',
    name: 'Analysis',
    component: () => import('@/pages/Analysis.vue'),
    meta: {
      title: '数据分析'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = (to.meta.title as string) || '房贷计算器'
  next()
})

export default router 